package cn.iocoder.yudao.module.blog.dal.mysql.space;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.blog.dal.dataobject.space.BlogSpaceDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.blog.controller.admin.space.vo.*;

/**
 * 动态 Mapper
 *
 * @author 曹建伟
 */
@Mapper
public interface BlogSpaceMapper extends BaseMapperX<BlogSpaceDO> {

    default PageResult<BlogSpaceDO> selectPage(BlogSpacePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BlogSpaceDO>()
                .eqIfPresent(BlogSpaceDO::getMemberId, reqVO.getMemberId())
                .eqIfPresent(BlogSpaceDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(BlogSpaceDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BlogSpaceDO::getId));
    }

    default List<BlogSpaceDO> selectList(BlogSpaceExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<BlogSpaceDO>()
                .eqIfPresent(BlogSpaceDO::getMemberId, reqVO.getMemberId())
                .eqIfPresent(BlogSpaceDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(BlogSpaceDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BlogSpaceDO::getId));
    }

}
